<?php

namespace app\admin\model\zhongzhuan\feiyu;

use think\Model;


class Huichuan extends Model
{

    

    

    // 表名
    protected $name = 'ec_aiuser_to_ecuser_feiyu_log';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'huichuantime_text',
        'step_text'
    ];
    

    
    public function getStepTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['step']) ? $data['step'] : '');
        $list = $this->getStages();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getHuichuantimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['huichuantime']) ? $data['huichuantime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setHuichuantimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }
    
    public function getClueList(){
        $list =  [0=>'不回传',"194"=>'信息确认',"195"=>'加为好友',"196"=>'高潜成交'];
        return $list;
    }
    
    
    public function getStages(){
        $list = [
            0=>'新客户',1=>'产生意向',2=>'可跟进客户',3=>'邀约上门',4=>'合作客户',
        ];
        return $list;
      
    }

    



    public function getLabelConfig($name){
        $list = db('ec_label')->where('labelGroupName','in',['微信情况','意向程度'])->select();
        $end_list = [];
        foreach ($list as $value){
            $labelList = json_decode($value['labelList'],true);
            foreach ($labelList as $v){
                $end_list[$value['labelGroupName']][$v['labelId']] = $v['labelName'];
            }
            
        }
        return $end_list[$name];
    }


}
